#!/bin/bash
# This script takes one argument: the path to the jscoverage executable

set -e

# Default to /usr/local/bin/jscoverage if no executable is specified.
if [ -z $1 ]
then
  JSCOVERAGE="C:/OpenSource/commandtools/unixutils/usr/local/wbin/jscoverage.exe"
else
  JSCOVERAGE=$1
fi

# Make sure this is run from the root of the project.
cd `hg root`

mkdir -p build/instrumented
$JSCOVERAGE jquery build/instrumented

# Create a modified version of the jQuery home page for testing purposes.
# See serve.js.
mkdir -p build/test/jquery.com/
sed -e 's#http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js#http://localhost:1985/build/instrumented/jquery-1.4.2.js#' \
    test/jquery.com/index.html > build/test/jquery.com/index.html
